package com.xinqi.modules.course.classmenu.factory;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.course.classmenu.client.ClassMenuInitClient;
import com.xinqi.modules.course.classmenu.dto.req.ClassMenuInitQueryDTO;
import com.xinqi.modules.course.classmenu.dto.rsp.ClassMenuInitResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 版块设置基础信息表降级处理
 *
 * @author: linkai
 * @date: 2023/10/25
 */
@Slf4j
@Component
public class ClassMenuInitFallbackFactory implements FallbackFactory<ClassMenuInitClient> {

    @Override
    public ClassMenuInitClient create(Throwable throwable) {
        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new ClassMenuInitClient() {
            @Override
            public R<PageInfo<ClassMenuInitResultDTO>> page(ClassMenuInitQueryDTO dto) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<ClassMenuInitResultDTO> findById(Long id) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

        };
    }
}
